
***This whisker plot is based on the final regression analysis
clear matrix 
*cd C:\Users\Tina\Desktop\EE
cd C:\Users\ychuang\Dropbox\ee\Analysis\analysis
insheet using .\regression_figure_list3_new.csv, comma names clear

**destring those to numeric
destring match1 match3 se1 se2, force ignore("*" "(" ")") replace

drop if v1==""



gen ci95_match1=match1+1.96*se1
gen ci05_match1=match1-1.96*se1

gen ci95_match3=match3+1.96*se2
gen ci05_match3=match3-1.96*se2

*make it more readable
format match3 %12.3f


gen product=10 if v1=="Appliance"
replace product=20 if v1=="Consumer Electronics"
replace product=30 if v1=="HVAC"
replace product=40 if v1=="Lighting"
replace product=50 if v1=="Pool Pump"
replace product=60 if v1=="Refrigeration"
*replace product=70 if v1=="Water Heating"
replace product=70 if v1=="Audits"
replace product=80 if v1=="Whole house retrofit"
replace product=90 if v1=="Building envelope"
*replace product=80 if v1=="Other"


# delimit ;
cap label  drop product;
cap label define product 10 "Appliance"
20  "Consumer Electronics"
30  "HVAC"
40  "Lighting"
50  "Pool Pump"
60  "Refrigeration"
70 "Audits"
80 "Whole house retrofit"
90 "Building shell";

label value product product;
# delimit cr

/*
# delimit ; 
twoway (rcap ci95_match3 ci05_match3 product , hor  lwidth(thin))||(scatter product match3 , msymbol(circle)  msize(small) mlabel(match3 )),
ylabel(10 20 30 40 50 60 70 80 90 100, valuelabel angle(0) labsize(small)) ytitle("Energy Efficiency Upgrade Program") 
xtitle("Regression coefficients and 95% confidence intervals", size(small))  xlabel(-0.4(0.1)0.5, labsize(small)) 
xscale(range(-0.4 0.4)) yscale(reverse) ysize(20) xsize(20) xline(0, lpattern(shortdash)) 
legend(order(2 "match list 2") ) ; 
# delimit cr
*/

# delimit ; 
twoway (rcap ci95_match3 ci05_match3 product , hor  lwidth(vthin) )||(scatter product match3 , msymbol(circle)  msize(small) mlabel(match3) mlabcolor(navy)   ),
ylabel(10 20 30 40 50 60 70 80 90, valuelabel angle(0) labsize(small)) ytitle("Energy Efficiency Upgrade Program") 
xtitle("Regression coefficients and 95% confidence intervals", size(small))  xlabel(-0.2(0.1)0.2, labsize(small)) 
xscale(range(-0.2 0.2)) yscale(reverse) ysize(18) xsize(20) xline(0, lpattern(shortdash))  
legend(order(2 "Effect on log(Kilowatt hours per month)") ) ; 
# delimit cr

graph export C:\Users\ychuang\Dropbox\ee\whiskerplot_list3.png,replace

/*
*********
graph export W:\CCEP\postdocs\Yating\Energy\Paper\Econ_paper\whiskerplot.png,replace
graph export W:\CCEP\postdocs\Yating\Energy\Paper\Econ_paper\whiskerplot.eps,replace
*/
/*
# delimit ; 
twoway (rcap ci95 ci05 preftype if pref=="ricktime", hor  lwidth(thin))|| (scatter  preftype coef if year=="0207", msymbol(triangle)  msize(small)   )||
(rcap ci95 ci05 preftype if pref=="stab_survey", hor lwidth(thin))|| (scatter  preftype coef if year=="0210", msymbol(square_hollow) msize(small) )||
(rcap ci95 ci05 preftype if pref=="stab_game", hor lwidth(thin))|| (scatter  preftype coef if year=="0709", msymbol(circle) msize(small)) || 
(scatter  preftype coef if year=="0710", msymbol(smdiamond_hollow)) ,
ylabel(10 20  40 50  70 80 90 100 120 130 140 150 160 170 180 190 200 210, valuelabel angle(0) labsize(small)) ytitle("Experiment                 Survey") 
xtitle("Regression coefficients and 90% confidence intervals", size(small))  xlabel(-0.8(0.2)0.8 , labsize(small)) 
xscale(range(-0.8 0.8)) yscale(reverse) ysize(20) xsize(18) xline(0, lpattern(shortdash)) yline (30) yline (110)
legend(order(2 "0207" 4 "0210" 6 "0709" 7 "0710") ) ; 
# delimit cr
*/
